/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-21 17:28:21
 * @LastEditTime : 2023-05-22 13:40:44
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\Dictionary.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'

export const Dictionary = async ({ uuid, url, OptionsEvent }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, dictionaryTypeUuid: uuid },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        // exportExcel: true,
        options: [
            <AddDataButton
                OptionsEvent={OptionsEvent}
                type="primary"
                icon="add"
                url={url}
                title="新增字典"
                AddTo={{ key: 'dictionaryTypeUuid', uuid }}
            />,
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName, title: '类型名称' },
            {
                dataIndex: 'fullName',
                title: '全名称',
                valueType: 'hidden',
                width: 200,
                hidden: true,
                hideInTable: true,
                hideInSearch: true,
            },
            commonTableList.code,
            {
                dataIndex: 'dictionaryTypeUuid',
                title: '父节点',
                valueType: 'hidden',
                hideInTable: true,
                hideInSearch: true,
                initialValue: uuid,
            },
            // commonTableList.parentUuid,
            { ...commonTableList.isEnabled, rules: true },
            { ...commonTableList.sortId, rules: true },
            commonTableList.remark,
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 140,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" url={url} data={record} />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="delete"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
